/**
 * 防止多次调用showLoading
 * 解决showLoading和hideLoading不成对调用会闪烁的问题
 * @class ShowLoading
 * @author liruilin
 * @date 2025/4/1
 */
class ShowLoading {
    #_length = 0;
    show(){
        if(this.#_length <= 0){
            uni.showLoading()
        }
        this.#_length ++
    }
    /**
     * 直接隐藏loading
     * @param {Boolean} isForce 是否强制隐藏loading
     */
    hide(isForce = false){
        if(isForce){
            this.#_length = 0
            uni.hideLoading()
            return
        }
        if(this.#_length <= 0) return
        if(this.#_length === 1){
            uni.hideLoading()
        }
        this.#_length --
    }
}

export default (new ShowLoading())